/*
 *  levelUpGame - BoundingBox.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef BOUNDING_BOX_H
#define BOUNDING_BOX_H

#include "ofTypes.h"

class ofRectangle;

class BoundingBox {
public:
	BoundingBox();
	explicit BoundingBox( const ofRectangle& bBox_ );
	BoundingBox( float x_, float y_, float w_, float h_ );
	
	virtual ~BoundingBox();
	
	void draw() const; //NOTE: for debugging purposes only
	
	const ofRectangle& getBBox() const;
	const ofPoint& getPosition() const;
	float getCollisionBBoxScale() const;
	
	void setCollisionBBoxScale( float scale_ );
	virtual void setPosition( const ofPoint& pos_ );
	virtual void setPosition( float x_, float y_ );
	virtual void setSize( const ofPoint& dims_ );
	virtual void setSize( float w_, float h_ );
	void setBBox( float x_, float y_, float w_, float h_ );
	void setBBox( const ofPoint& p_, float w_, float h_ );
	void setCenteredBBox( float x_, float y_, float w_, float h_ );
	void setCenteredBBox( const ofPoint& p_, float w_, float h_ );
	void revert();
	
	bool overlapsWith( const BoundingBox& other_ ) const;
	//bool isInside( const BoundingBox& other_ ) const;
	
	static void scaleRectangle( ofRectangle& rect_, float scale_ );
	
private:
	float collisionBBoxScale;
	ofPoint coords, prevCoords;
	ofRectangle bBox, prevBBox;
	
	void recalcFromPosition( float x_, float y_ );
	void recalcFromBBox( float x_, float y_, float w_, float h_ );
	void recalcFromBBox( const ofRectangle& bBox_ );
	void recalcFromDimensions( float w_, float h_ );
};

#endif /* ! BOUNDING_BOX_H */
